<div class="config-container">
<h3>Jobs</h3>
<div class="instructions">
    Manage jobs for this stage. All these jobs will be run in parallel (given sufficient matching agents), so they should not depend on each other.
</div>
<table class="list_table reorderable_table jobs_list_table">
    <thead>
    <tr>
        <th>Job</th>
        <th>Resources</th>
        <th>Run on all</th>
        <th>Run multiple instances</th>
      <% unless @is_config_repo_pipeline %>
        <th class="remove">Remove</th>
      <% end %>
    </tr>
    </thead>
    <tbody>
    <% @jobs.each do |job_config| %>
        <tr>
            <td><%= link_to(job_config.name(), admin_tasks_listing_path(:job_name => job_config.name(), :current_tab => "tasks")) %></td>
            <td><%= job_config.resourceConfigs().join(', ') %></td>
            <td><%= job_config.isRunOnAllAgents() ? 'Yes' : 'No' %></td>
            <td><%= job_config.isRunMultipleInstanceType() ? 'Yes' : 'No' %></td>
          <% unless @is_config_repo_pipeline %>
            <td class="remove">
                <% if @jobs.size() > 1 %>
                    <% unique_delete_job_id = random_dom_id("delete_job_") %>
                    <%= form_for job_config, :as => '', :url => {:action => "destroy", :job_name => job_config.name()},
                                :html => {:id => "#{unique_delete_job_id}", :method => :delete} do |f| %>
                        <%= md5_field %>
                        <span class="icon_remove delete_parent" id="trigger_<%= unique_delete_job_id %>">
                            <%= render :partial => 'admin/shared/submit_with_prompt.html',
                                       :locals => {:scope => {
                                               :button_id => "trigger_#{unique_delete_job_id}",
                                               :message => "Are you sure you want to delete the job '#{job_config.name()}' ? ",
                                               :on_confirmation_js => "$('#{"#{unique_delete_job_id}"}').submit()"}} %>
                            </span>
                    <% end %>
                <% else %>
					<%= action_icon({:type => "delete", :disabled => true, :title => ""}) %>
                <% end %>
            </td>
          <% end %>
        </tr>
    <% end %>
  <% unless @is_config_repo_pipeline %>
    <tr>
        <td colspan="5">
            <a class="add_link" href="#" onclick="ModalBoxWhichClosesAutoCompleteDropDownBeforeClosing.show('<%= admin_job_new_path -%>', {overlayClose: false, title: 'Add new job'})">Add new job</a>
        </td>
    </tr>
  <% end %>
    </tbody>
</table>
</div>
<script type="text/javascript">
    AjaxForm.error_box_selector = '#MB_content';
</script>
